package Controller.listeners;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import Model.RegulaFalsi;
import View.MainView;

public class RegulaFalsiListener implements ActionListener {

	private MainView view;
	private RegulaFalsi model;
	
	public RegulaFalsiListener() {
		view = null;
		model = null;
	}
	
	public RegulaFalsiListener(MainView view, RegulaFalsi model) {
		this.view = view;
		this.model = model;
	}
	
	@Override
	public void actionPerformed(ActionEvent arg0) {
		model.clearList();
		view.resetRegulaFalsi();
		model.setValues(view.getX0(), view.getX1(), view.getRIteration(), view.getRFunction(), view.getRThreshold());
		model.computeRegulaFalsi();
		view.setModelRegulaFalsi(model.getx0List(), model.getx1List(), model.getx2List(), model.gety0List(), 
				model.gety1List(), model.gety2List(), model.getTrueXList(), model.getTrueYList(), model.getThresholdList());
		view.updateRegulaFalsiChart();
	}
}
